class SceneVictoryeEnd extends GuaScene {
    constructor(game) {
        super(game)
        this.setup()
    }

    setup() {
        this.context = this.game.context
        this.currentLevel = []
        this.setupBG()
        this.setupInputs()

    }

    draw() {
        super.draw()
        this.game.drawText('下一关', 470, 300)
    }

// setup 系列
    setupBG() {
        let lbg = LEVEL[0]
        let back = getbg(lbg)
        let bg1 = GuaImage.new(this.game, back)
        this.addElement(bg1)
        let bg = PlantIcon.new(this.game, 'GameVictory')
        this.bg = bg
        this.addElement(bg)
        // this.game.drawText('下一关', 470, 63)
    }


    setupInputs() {
        let self = this
        self.game.registerMouse(function (event, status) {
            let x = event.offsetX
            let y = event.offsetY
            if (status === 'down') {
                log(x, y)
                // 470, 300
                if (x > 460 && x < 560 && y > 270 && y < 310) {
                    if (LEVEL[1] === 9) {
                        LEVEL[0] += 1
                    } else {
                        LEVEL[1] += 1
                    }
                    self.updateScene()
                }
            }
        })

    }

    updateScene() {
        // if (LEVEL[0] > 1) {
        //     sleep(500).then(() => {
        //         let s = SceneEditor.new(this.game)
        //         this.game.replaceScene(s)
        //     })
        // } else {
        //     sleep(500).then(() => {
        //         let s = SceneTitle.new(this.game)
        //         this.game.replaceScene(s)
        //     })
        // }

        sleep(500).then(() => {
            let s = SceneEditor.new(this.game)
            this.game.replaceScene(s)
        })
        this.game.removeMouse()
    }
}


